package com.cckat.controller;

import com.cckat.entity.Admin;
import com.cckat.entity.Permission;
import com.cckat.service.AdminService;
import com.cckat.service.PermissionService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author 静海基地
 */
@Controller
public class FrameController {


    @DubboReference
    private AdminService adminService;

    @DubboReference
    private PermissionService permissionService;



    @RequestMapping("/")
    public String index(Model model){
        //因为现在还未引入权限认证框架，没有登录，所以现在先将用户的id写死，等集成了权限认证框架之后，再获取当前登录的用户
        Long adminId = 1L;
        Admin admin = adminService.getById(adminId);
        //查询用户的权限列表
        List<Permission> permissionList = permissionService.findMenuListByAdminId(adminId);
        model.addAttribute("admin",admin);
        model.addAttribute("permissionList",permissionList);
        return "frame/index";
    }


    /**
     * 框架主页
     * @return
     */
    @RequestMapping("/main")
    public String main(){
        return "frame/main";
    }

}
